<template>
  <div class="container">
    <div class="search-box">
      <el-row :gutter="20">
        <el-form label-width="100px" size="small" class="searchForm">
          <el-col :span="6">
            <el-form-item label="公司名称:">
              <el-input
                v-model="params.companyName"
                size="mini"
                clearable
                @keyup.enter.native="search"
                @clear="search"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="客户邮箱:">
              <el-input
                v-model="params.email"
                size="mini"
                clearable
                @keyup.enter.native="search"
                @clear="search"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="客户姓名:">
              <el-input
                v-model="params.customerName"
                size="mini"
                clearable
                @keyup.enter.native="search"
                @clear="search"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="客户等级:">
              <el-select
                v-model="params.grade"
                placeholder="请选择客户等级"
                size="mini"
                clearable
                @change="search"
              >
                <el-option
                  v-for="item in levelList"
                  :key="item.gradeValue"
                  :label="item.gradeName"
                  :value="item.gradeValue"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="客户类型:">
              <el-select v-model="params.customerRole" clearable @change="search">
                <el-option
                  v-for="item in levelList3"
                  :key="item.dictValue"
                  :label="item.dictLabel"
                  :value="item.dictValue"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="标签:">
              <!-- <el-autocomplete
                class="inline-input"
                v-model="params.label"
                :fetch-suggestions="querySearch"
                placeholder="请输入内容"
                value-key="context"
                clearable
                @change="search"
              ></el-autocomplete> -->
              <el-select v-model="params.label" clearable placeholder="请选择标签" @change="search">
                <el-option
                  v-for="item in labels"
                  :key="item.id"
                  :label="item.context"
                  :value="item.context"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="来源:">
              <el-select v-model="params.source" clearable @change="search">
                <el-option
                  v-for="item in levelList5"
                  :key="item.dictValue"
                  :label="item.dictLabel"
                  :value="item.dictValue"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <!-- <el-col :span="6">
            <el-form-item label="国家:">
              <el-input
                v-model="params.country"
                size="mini"
                clearable
                @keyup.enter.native="search"
                @clear="search"
              ></el-input>
            </el-form-item>
          </el-col> -->
          <el-col :span="6">
            <el-form-item label="联系电话:">
              <el-input
                v-model="params.customerPhone"
                size="mini"
                clearable
                @keyup.enter.native="search"
                @clear="search"
              ></el-input>
            </el-form-item>
          </el-col>
          <!-- <el-col :span="6">
            <el-form-item label="客户官网:">
              <el-input
                v-model="params.officialWebsite"
                size="mini"
                clearable
                @keyup.enter.native="search"
                @clear="search"
              ></el-input>
            </el-form-item>
          </el-col> -->
          <!-- <el-col :span="6">
            <el-form-item label="最近跟进人:" v-if="!openFlag">
              <el-select
                v-model="params.ids"
                clearable
                @change="search"
              >
                <el-option
                  v-for="item in sysUserList"
                  :key="item.userId"
                  :label="item.userName"
                  :value="item.userId"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col> -->
          <el-col :span="6">
            <el-button
              @click="search"
              icon="el-icon-search"
              size="mini"
              type="primary"
              >搜索</el-button
            >
            <!-- <el-button
              icon="el-icon-folder-opened"
              type="primary"
              size="mini"
              @click="openSearch"
              >展开</el-button
            > -->
            <el-button
              @click="cancelData"
              icon="el-icon-circle-close"
              size="mini"
              type="warning"
              >重置</el-button
            >
          </el-col>
          <!-- <el-col :span="6" v-if="!openFlag">
            <el-button
              @click="search"
              icon="el-icon-search"
              type="warning"
              size="mini"
              >搜索</el-button
            >
            <el-button
              @click="openSearch"
              icon="el-icon-folder-opened"
              type="primary"
              size="mini"
              >收起</el-button
            >
            <el-button
              @click="cancelData"
              icon="el-icon-circle-close"
              size="mini"
              type="success"
              >重置</el-button
            >
          </el-col> -->
        </el-form>
      </el-row>
    </div>

    <div class="container">
      <div class="handle-box">
        <!-- <span class="title">重复客户列表</span> -->
        <el-button
          size="mini"
          type="danger"
          icon="el-icon-delete"
          class="handle-del mr10"
          :disabled="multiple"
          @click="delAllSelection"
          >批量删除</el-button
        >
      </div>
      <el-table
        v-loading="loading"
        :data="tableData"
        :max-height="tableHeight"
        style="width: 100%;"
        border
        class="table"
        ref="multipleTable"
        header-cell-class-name="table-header"
        @selection-change="handleSelectionChange"
      >
        <el-table-column
          type="selection"
          width="55"
          align="center"
        ></el-table-column>
        <el-table-column fixed label="公司名称" width="260" align="center" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            <span
              class="blue"
              style="text-decoration: underline; margin-left: 5px"
              @click="handleEdit(scope.$index, scope.row)"
              >{{ scope.row.companyName }}</span
            >
          </template>
        </el-table-column>
        <el-table-column
          prop="email"
          label="客户邮箱"
          align="center"
          min-width="160"
          fixed
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column
          prop="customerName"
          label="客户姓名"
          min-width="100"
          align="center"
          fixed
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column label="客户等级" width="140" align="center">
          <template slot-scope="scope">
            <span>{{ formatLevel(scope.row.grade) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="客户类型" align="center" min-width="100">
          <template slot-scope="scope">
            <span>{{ formatRole(scope.row.customerRole) }}</span>
          </template>
        </el-table-column>
        <!-- <el-table-column
          prop="officialWebsite"
          label="客户官网"
          align="center"
          min-width="160"
          :show-overflow-tooltip="true"
        ></el-table-column> -->
        <el-table-column label="标签" width="100" align="center">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.label">{{ scope.row.label }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="来源" align="center" width="120">
          <template slot-scope="scope">
            <span>{{ formatSource(scope.row.source) }}</span>
          </template>
        </el-table-column>
        <!-- <el-table-column
          label="国家"
          align="center"
          width="120"
          :show-overflow-tooltip="true"
        >
          <template slot-scope="scope">
            {{scope.row.country}}
          </template>
        </el-table-column> -->
        <el-table-column
          label="联系电话"
          width="150"
          align="center"
          prop="customerPhone"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <!-- <el-table-column
          label="更多电话"
          width="150"
          align="center"
          prop="landlinePhone"
          :show-overflow-tooltip="true"
        >
        </el-table-column> -->
        <el-table-column
          prop="userName"
          label="资源归属"
          align="center"
          width="150"
        ></el-table-column>
        <el-table-column
          label="备注"
          align="center"
          width="150"
          prop="remark"
          :show-overflow-tooltip="true"
        />
        <!-- <el-table-column
          label="最近小记内容"
          align="center"
          width="150"
          prop="subtotal"
          :show-overflow-tooltip="true"
        /> -->
        <!-- <el-table-column label="最近小记时间" align="center" min-width="120">
          <template slot-scope="scope">{{ smallTime(scope.row.updateTime) }}</template>
        </el-table-column> -->
        <el-table-column label="创建时间" align="center" min-width="160">
          <template slot-scope="scope">{{ scope.row.createTime }}</template>
        </el-table-column>
        <!-- <el-table-column
          label="操作"
          min-width="180"
          align="center"
          fixed="right"
        >
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="warning"
              icon="el-icon-s-promotion"
              @click="handleOrder(scope.$index, scope.row)"
              >预约</el-button
            >
            <el-button
              type="primary"
              size="mini"
              icon="el-icon-view"
              @click="handleViewLog(scope.$index, scope.row)"
              >小记</el-button
            >
            <el-button
              type="success"
              size="mini"
              icon="el-icon-edit"
              @click="handleEdit(scope.$index, scope.row)"
              >修改</el-button
            >
          </template>
        </el-table-column> -->
      </el-table>
      <div class="pagination">
        <pagination
          v-show="pageTotal > 0"
          :total="pageTotal"
          :page.sync="params.pageNum"
          :limit.sync="params.pageSize"
          @pagination="getData00"
        />
      </div>
    </div>

    <!-- 修改增加 -->
    <!-- <el-dialog :title="title666" :visible.sync="dialogVisible" width="1200px">
      <el-form
        :rules="rules2"
        ref="ruleForm"
        :model="formData"
        label-width="120px"
        size="small"
        class="form-box"
      >
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="公司名称" prop="companyName">
              <el-input
                v-model="formData.companyName"
                :disabled="editFlags"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="客户邮箱" prop="email">
              <el-input v-model="formData.email">
                <el-button slot="append" icon="el-icon-coordinate" @click.stop="yanzheng"></el-button>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="客户姓名" prop="customerName">
              <el-input v-model="formData.customerName"></el-input>
            </el-form-item>
          </el-col>
          
          <el-col :span="8">
            <el-form-item label="客户等级" prop="grade">
              <el-select v-model="formData.grade">
                <el-option
                  v-for="item in levelList"
                  :key="item.gradeValue"
                  :label="item.gradeName"
                  :value="item.gradeValue"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="客户类型" prop="customerRole">
              <el-select v-model="formData.customerRole">
                <el-option
                  v-for="item in levelList3"
                  :key="item.dictValue"
                  :label="item.dictLabel"
                  :value="item.dictValue"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="联系电话" prop="customerPhone">
              <el-input v-model="formData.customerPhone"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="客户官网" prop="officialWebsite">
              <el-input v-model="formData.officialWebsite"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="新/老客户" prop="customerType">
              <el-select v-model="formData.customerType">
                <el-option
                  v-for="item in levelList2"
                  :key="item.id"
                  :label="item.title"
                  :value="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="来源" prop="source">
              <el-select v-model="formData.source" @change="change123">
                <el-option
                  v-for="item in levelList5"
                  :key="item.dictValue"
                  :label="item.dictLabel"
                  :value="item.dictValue"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="国家" prop="country">
              <el-select
                v-model="formData.country"
                placeholder="请选择所属国家"
                size="mini"
                clearable
                filterable
                @change="choose_country"
              >
              <el-option
                v-for="item in countryList"
                :key="item.id"
                :label="item.country"
                :value="item.country"
              ></el-option>
            </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="城市" prop="city">
              <el-input v-model="formData.city"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="详细地址" prop="address">
              <el-input v-model="formData.address"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="备注">
              <el-input
                type="textarea"
                autosize
                v-model="formData.remark">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false" size="small">取消</el-button>
        <el-button @click="submitForm()" type="primary" size="small"
          >确定</el-button
        >
      </span>
    </el-dialog> -->
  </div>
</template>
<script>
import {
  allDel,
  callNumber,
  getList,
  execlSubmitForm,
  handleOrderListDelete,
  getRemains,
  orderSubmitForm,
  deleteData,
  getData00,
  uploadFile,
  submitAptitudeForm,
  submitAptitudeForm2,
  update,
  downLoadPan,
  submitFormadd,
  getLabels,
  userList,
  addRecord,
  getCountryList,
  exportWai,
  validateEmail
} from "@/api/systemSettings/customerManagement";
import {
    getData,
    delCusomer
} from "@/api/systemSettings/sameCustomer"
import { listUser } from "@/api/systemSettings/resource";
import { list } from "@/api/systemSettings/grade";

// import logDialog from "./logDialog.vue";
// import contractDialog from "./contractDialog.vue";
export default {
//   components: { logDialog },
  data() {
    return {
      // 转移
      countryList:[],
      translateVisible:false,
      peopleLists:[],
      moveUser:undefined,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      labels: [],
      cont: undefined,
      sysUserList: [],
      label: "",
      uploadFile666: {},
      dialogVisible555: false,
      dialogVisible666: false,
      dialogVisible888: false,
      applyListData888: [],
      // pageNum888:1,
      // todelpage888:0,
      uploading: false,
      openFlag: true,
      title666: "",
      addVisible: false,
      del: false,
      uploadList: [],
      loading: true,
      //tHeight:document.body.offsetHeight - 350,
      //数据
      tableData: [],
      tableHeight: 0,
      // 参数
      paramsFlag: 0,
      params: {
        pageNum: 1,
        pageSize: 10
      },
      pageTotal: 0,
      orderParamsTotal: 0,
      dialogVisible: false, // 是否展示编辑页面
      // 数据
      formData: {},
      dialogStatus: 0,
      //资质查看
      viewDialogVisible: false,
      //日志查看
      logDialogVisible: false,
      //合同列表
      logDiaContractVisible: false,
      stateList: [
        {
          id: 1,
          title: "已合作",
        },
        {
          id: 2,
          title: "有意向",
        },
        {
          id: 3,
          title: "待开发",
        },
      ],
      moveStatList: [
        {
          id: 0,
          title: "正常",
        },
        {
          id: 1,
          title: "待迁移",
        },
      ],
      levelList: [],
      levelList3: [],
      levelList5: [],
      levelList2: [
        // {
        //   id: "0",
        //   title: "未知",
        // },
        {
          id: "1",
          title: "新客户",
        },
        {
          id: "2",
          title: "老客户",
        },
      ],
      qccQuery: [
        {
          id: true,
          title: "已查",
        },
        {
          id: false,
          title: "未查",
        },
      ],
      //转移申请
      rules: {
        targetUid: [
          { required: true, message: "请输入被转移人", trigger: "change" },
        ],
        type: [
          { required: true, message: "请选择申请类型", trigger: "change" },
        ],
        ids: [{ required: true, message: "请选择转移客户", trigger: "change" }],
        remainTime: [
          { required: true, message: "请选择预约时间", trigger: "change" },
        ],
        ExeclParams: [
          {
            required: true,
            message: "客户资源导出数量不能为空",
            trigger: "blur",
          },
        ],
      },
      rules2: {
        // landlinePhone: [
        //   { required: true, message: "请输入座机电话", trigger: "change" },
        // ],
        email: [
          { required: true, message: "邮箱地址不能为空", trigger: "blur" },
          // {
          //   type: "email",
          //   message: "'请输入正确的邮箱地址",
          //   trigger: ["blur", "change"],
          // },
        ],
        // customerPhone: [
        //   { required: true, message: "请输入联系电话", trigger: "blur" },
        // ],
        companyName: [
          { required: true, message: "请输入公司名称", trigger: "blur" },
        ],
        country: [
          { required: true, message: "请选择国家", trigger: "blur" },
        ],
        customerName: [
          { required: true, message: "请输入联系人", trigger: "blur" },
        ],
        // address: [
        //   { required: true, message: "请输入地址", trigger: "blur" },
        // ],
        customerRole:[
          { required: true, message: "请选择客户类型", trigger: "blur" },
        ],
        grade:[
          { required: true, message: "请选择客户等级", trigger: "blur" },
        ],
        customerType:[
          { required: true, message: "请选择新老客户", trigger: "blur" },
        ],
        source:[
          { required: true, message: "请输入客户来源", trigger: "blur" },
        ]
      },
      isLogin: false,
      applyVisible: false,
      sysUserList: [],
      applyData: {
        //   sourceUid:JSON.parse( localStorage.getItem('adminData') ).id,
        type: "",
        targetUid: "",
        ids: "",
        reason: "",
      },
      typeList: [
        {
          title: "部分转移",
          id: 1,
        },
        {
          title: "全部转移",
          id: 2,
        },
      ],
      //查看申请
      viewApplyVisible: false,
      // adminId:JSON.parse( localStorage.getItem('adminData') ).id,
      ApplyListParams: {
        pageNum: 1,
        pageSize: 10,
      },
      applyListData: [],
      applyListPage: 0,
      statelList: [
        {
          id: "0",
          title: "未审核",
        },
        {
          id: "1",
          title: "通过",
        },
        {
          id: "2",
          title: "拒绝",
        },
      ],
      applyDetailVisible: false,
      customerListParams: {
        pageNum: 1,
        pageSize: 10,
      },
      customerListParamsTotal: 0,
      customerListDataMore: [],
      statusData: [
        {
          id: 0,
          title: "未审核",
        },
        {
          id: 1,
          title: "已审核",
        },
        {
          id: 2,
          title: "全部",
        },
      ],
      status: "",
      //客户预约
      orderVisible: false,
      orderData: {},
      orderDialogStatus: "",
      viewOrderListVisible: false,
      orderLstData: [],
      messageContent: "",
      //表格导出
      ExeclParamsdata: {
        ExeclParams: "",
      },
      addExeclVisible: false,
      editFlags: false,
      // 转移人员
      transferPeopleParams: {
        pageNum: 1,
        pageSize: 10,
        companyName: "",
        realName: "",
        grade: "",
      },
      options: [],
      corporateNameTitle: "",
      contractFlag: true,
      orderParams: {
        pageNum: 1,
        pageSize: 10,
      },
      translate_data:{}
    };
  },
  computed: {},
  created() {
    // if(this.$route.params.id){
    //   this.openFlag = !this.openFlag;
    //   this.params.grade = this.$route.params.id;
    //   this.getData00()
    // }else if(this.$route.params.day){
    //   this.openFlag = !this.openFlag;
    //   this.params.day=this.$route.params.day;
    //   this.params.relation='0';
    //   this.getData00();
    // }else{
    //   this.getData00();
    // };
    this.getData00();
    this.getDicts("qudao").then((res) => {
      this.levelList5 = res.data;
      console.log(res.data,'yuanshi')
      // console.log(this.levelList5,'12')
    });
    // this.getRemains();
    // this.getSysUserList();
  },
  mounted() {
    this.$nextTick(function() {
      this.tableHeight = window.innerHeight - this.$refs.multipleTable.$el.offsetTop - 200;
      let self= this;
      window.onresize = function(){
        self.tableHeight = window.innerHeight - self.$refs.multipleTable.$el.offsetTop - 200;
      }
      // console.log(self.tableHeight,'表格高度')
      console.log(window.innerHeight,'')
    });
    this.getDicts("customerRole").then((response) => {
      this.levelList3 = response.data;
    });
    // this.peopleList();
    // this.getLabels();
    this.grades();
    // this.getCountryList()
    // this.getList();
  },
  watch: {},
  filters: {
    formatDate: function (value) {
      /* let date = new Date(parseInt(value) * 1000);
        let y = date.getFullYear();
        let m = date.getMonth() + 1;
        m = m < 10 ? "0" + m : m;
        let d = date.getDate();
        d = d < 10 ? "0" + d : d;
        return y+'-'+m + "-" + d;*/
      let date = new Date(parseInt(value) * 1000);
      let y = date.getFullYear();
      let m = date.getMonth() + 1;
      m = m < 10 ? "0" + m : m;
      let d = date.getDate();
      d = d < 10 ? "0" + d : d;
      let h = date.getHours();
      h = h < 10 ? "0" + h : h;
      let minute = date.getMinutes();
      let second = date.getSeconds();
      minute = minute < 10 ? "0" + minute : minute;
      second = second < 10 ? "0" + second : second;
      return y + "-" + m + "-" + d + " " + h + ":" + minute + ":" + second;
    },
  },
  methods: {
    smallTime(val){
      return val.substring(0,10)
    },
    translate(row){
      this.translateVisible=true;
      this.translate_data=row;
      console.log(row)
    },
    // handleCurrentChange888(e){
    //   this.pageNum888=e
    // },
    // 获取客户等级
    grades() {
      list({
        pageNum: 1,
        pageSize: 100,
      }).then((response) => {
        console.log(response);
        this.levelList = response.rows;
      });
    },
    querySearch(queryString, cb) {
      console.log(queryString, this.labels);
      var restaurants = this.labels;
      var results = queryString
        ? restaurants.filter(this.createFilter(queryString))
        : restaurants;
      // 调用 callback 返回建议列表的数据
      cb(results);
    },
    createFilter(queryString) {
      return (restaurant) => {
        return (
          restaurant.context
            .toLowerCase()
            .indexOf(queryString.toLowerCase()) === 0
        );
      };
    },
    getLabels() {
      getLabels({
        pageNum: 1,
        pageSize: 9999,
      }).then((res) => {
        if (res.code == 200) {
          this.labels = res.rows;
        }
      });
    },
    jilu(id1, id2) {
      submitFormadd({
        content: this.cont,
        customerId: id1,
        userId: id2,
      }).then((res) => {
        if (res.code == 200) {
          this.cont = undefined;
          console.log("保存记录成功");
        }
      });
    },
    // getSysUserList() {
    //   listUser().then((res) => {
    //     this.sysUserList = res.rows;
    //   });
    // },
    close666() {
      this.uploadFile666 = {};
      this.uploadList = [];
    },
    // 最新新增
    submitForm() {
      console.log(this.formData,'biaoda')
      this.$refs["ruleForm"].validate((valid) => {
        if (valid) {
          if (!this.formData.id) {
            // this.formData.userId = localStorage.getItem("useId");
            submitAptitudeForm(this.formData).then((res) => {
              console.log(res);
              if (res.code == 200) {
                this.$message.success(`新增成功`);
                this.dialogVisible = false;
                this.getData00();
              }
            });
          } else {
            console.log(this.formData);
            update(this.formData).then((res) => {
              if (res.code == 200) {
                this.jilu(this.formData.id, this.formData.userId);
                this.$message.success(`修改成功`);
                this.dialogVisible = false;
                this.uploading = false;
                this.getData00();
              }
            });
          }
        }
      });
    },
    formatJson(filterVal, jsonData) {
      return jsonData.map((v) => filterVal.map((j) => v[j]));
    },
    viewOrderList() {
      this.viewOrderListVisible = true;
      this.getRemains();
    },
    getRemains() {
      getRemains(this.orderParams).then((res) => {
        this.orderLstData = res.rows;
        this.orderParamsTotal = res.total;
      });
    },
    orderPageChange(val) {
      this.$set(this.orderParams, "pageNum", val);
      this.getRemains();
    },
    handleOrder(index, row) {
      this.orderVisible = true;
      this.orderData = {
        remainTime: "",
        remark: "",
        customerId: row.id,
      };
      this.orderDialogStatus = "新增预约";
    },
    orderSubmitForm(formName) {
      var _this = this;
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.isLogin = true;
          console.log(this.orderData);
          orderSubmitForm(this.orderData)
            .then((res) => {
              if (res.code != 200) {
                setTimeout(() => {
                  this.isLogin = false;
                  this.$message.error(`${this.orderDialogStatus}失败`);
                }, 0.1 * 1000);
              } else {
                setTimeout(() => {
                  this.isLogin = false;
                  this.$message.success(`${this.orderDialogStatus}成功`);
                  this.orderVisible = false;
                  this.getRemains();
                }, 0.1 * 1000);
              }
            })
            .catch(() => {
              this.isLogin = false;
            });
        }
      });
    },
    handleChange(params) {
      if (params == 2) {
        this.status = "";
      } else {
        this.status = params;
      }
      this.viewApply();
    },
    formatState(val) {
      var str = this.statelList.find(function (item) {
        return item.id == val;
      });
      if (str) return str.title;
    },
    openSearch() {
      this.openFlag = !this.openFlag;
      this.params = {
        pageNum: 1,
        pageSize: 10
      };
    },
    formatLevel(val) {
      var str = this.levelList.find(function (item) {
        return item.gradeValue == val;
      });
      if (str) return str.gradeName;
    },
    formatRole(val) {
      var str = this.levelList3.find(function(item) {
        return (item.dictValue == val);
      });
      if (str) return str.dictLabel;
    },
    formatSource(val) {
      var str = this.levelList5.find(function(item) {
        return (item.dictValue == val);
      });
      if (str) return str.dictLabel;
    },
    formatType(val) {
      var str = this.levelList2.find(function (item) {
        return item.id == val;
      });
      if (str) return str.title;
    },
    cancelData() {
      this.params = {
        pageNum: 1,
        pageSize: 10
      };
      this.getData00();
    },

    // 删除操作
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      console.log(this.ids)
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },
    delAllSelection(row) {
      const id = row.id || this.ids;
      this.$confirm("是否确认删除?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return delCusomer(id);
        })
        .then(() => {
          this.getData00();
          this.msgSuccess("删除成功");
        })
        .catch(function () {});
    },
    // 触发搜索按钮
    search() {
      this.$set(this.params, "pageNum", 1);
      this.paramsFlag = 0;
      this.getData00();
    },

    //新增页面弹窗
    handleAdd() {
      this.formData = {};
      this.dialogVisible = true;
      this.title666 = "新增";
    },
    handleEdit(index, row) {
      this.dialogVisible = true;
      this.title666 = "修改";
      submitAptitudeForm2(row.id).then((res) => {
        if (res.code == 200) {
          console.log(res);
          this.formData = res.data;
          console.log(this.formData,'12343')
        } else {
          this.$message.error(res.msg);
        }
      });
    },
    //编辑页面弹窗
    closeDialog() {
      this.dialogVisible = false;
    },
    //获取数据
    getData00() {
      let data = this.params;
      getData(data)
        .then((res) => {
          console.log(res, "重复客户列表");
          if (res.code == "200") {
            this.tableData = res.rows;
            this.pageTotal = res.total;
            this.loading = false;
          }
        })
        .catch(() => {
          console.log("error submit!!");
          return false;
        });
    },
    // 分页导航
    handlePageChange(val) {
      this.$set(this.params, "pageNum", val);
      this.getData00();
    },
  },
};
function formatDate(value) {
  let date = new Date(parseInt(value) * 1000);
  let y = date.getFullYear();
  let m = date.getMonth() + 1;
  m = m < 10 ? "0" + m : m;
  let d = date.getDate();
  d = d < 10 ? "0" + d : d;
  return y + "-" + m + "-" + d;

  /*  let date = new Date(parseInt(value) * 1000)
    let y = date.getFullYear();
    let m = date.getMonth() + 1;
    m = m < 10 ? ('0' + m) : m;
    let d = date.getDate();
    d = d < 10 ? ('0' + d) : d;
    let h = date.getHours();
    h = h < 10 ? ('0' + h) : h;
    let minute = date.getMinutes();
    let second = date.getSeconds();
    minute = minute < 10 ? ('0' + minute) : minute;
    second = second < 10 ? ('0' + second) : second;
    return  y + '-' + m + '-' + d + ' '+ h + ':' + minute + ':' + second*/
}
</script>

<style scoped>
.container {
  padding: 0 20px !important;
}
.title {
    font-size: 18px;
}
.ml20 {
    margin-left: 20px;
}
.timeDate .el-date-editor {
  width: 50%;
  float: left;
}
.handle-box .el-button + .el-button {
  margin-left: 0px !important;
}
.form-box,
.el-select {
  width: 100% !important;
}
.handle-box {
  margin-bottom: 10px;
}

.handle-select {
  width: 120px;
}

.handle-input {
  width: 300px;
  display: inline-block;
}
.table {
  width: 100%;
  font-size: 14px;
}

.yellow {
  color: #f57506;
}
.green {
  color: green;
  cursor: pointer;
}
.red {
  color: #ff0000;
}
.blue {
  color: #409eff;
  cursor: pointer;
  text-decoration: underline;
}
.blue1 {
  color: #409eff;
}
.mr10 {
  margin-right: 10px;
}
.table-td-thumb {
  display: block;
  margin: auto;
  width: 40px;
  height: 40px;
}
.search-box {
  margin-bottom: 10px;
  padding: 10px 10px 10px 10px;
  border-radius: 4px;
  box-sizing: border-box;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 5px;
}
.searchForm .el-form-item--mini.el-form-item,
.searchForm .el-form-item--small.el-form-item {
  margin-bottom: 1px;
}
</style>
